package com.itheima.controller;

import com.itheima.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Test1 {

//    @Value("${name}")
//    private String name11;
//    @RequestMapping("/test2")
//    public void test2(){
//        System.out.println(name11);
//    }

//    @Value("${person.name}")
//    private String name22;
//
//    @Value("${person.age}")
//    private int age;
//    @RequestMapping("/test3")
//    public void test3(){
//        System.out.println(name22);
//        System.out.println(age);
//    }

//    @Value("${Address[0]}")
//    private String a1;
//    @Value("${Address[1]}")
//    private String a2;
//
//    @RequestMapping("/test5")
//    public void test5(){
//        System.out.println(a1);
//        System.out.println(a2);
//    }

    @Autowired
    private Environment env;
    @RequestMapping("/test6")
    public void test6(){
        System.out.println(env.getProperty("person.name"));
        System.out.println(env.getProperty("person.age"));
        System.out.println(env.getProperty("name"));
    }

    @Autowired
    private Person person;


    @RequestMapping("/test1")
    public String test1(){
        System.out.println(person);
        String[] address = person.getAddress();
        for (String s : address) {
            System.out.println(s);
        }

        return "1111";
    }
}
